<?php
declare(strict_types=1);

namespace App\Utils;

class NativeLog
{
    private $dirPath;


    public function __construct()
    {
        $this->dirPath = BASE_PATH . '/runtime/logs/' . date("Ymd") . '/';
        if (!is_dir($this->dirPath)) {
            mkdir($this->dirPath, 0777, true);
        }
    }

    public function error(string $data) : bool
    {
        $data = "[ ERROR ] [" . date("Y-m-d H:i:s") . "] " . $data . PHP_EOL;
        file_put_contents($this->dirPath . "error.log", $data, FILE_APPEND);
        return true;
    }

    public function debug(string $data) : bool
    {
        $data = "[ DEBUG ] [" . date("Y-m-d H:i:s") . "] " . $data . PHP_EOL;
        file_put_contents($this->dirPath . "debug.log", $data, FILE_APPEND);
        return true;
    }

    public function info(string $data) : bool
    {
        $data = "[ INFO ] [" . date("Y-m-d H:i:s") . "] " . $data . PHP_EOL;
        file_put_contents($this->dirPath . "info.log", $data, FILE_APPEND);
        return true;
    }


}


